﻿using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yto.Common.Dependency;
using Yto.Repositories;

namespace com.ytocargo.Core.AirPortCharts
{
    public class AirPortChartStore : IAirPortChartStore, ITransient
    {
        private IBaseRepository<AirPortChart, string> _airPortChartRep;

        public AirPortChartStore(IBaseRepository<AirPortChart,string> repository)
        {
            _airPortChartRep = repository;
        }

        public IReadOnlyList<AirPortChart> GetAirPortCharts()
        {
            return _airPortChartRep.GetAll().ToImmutableList();
        }

        public void Insert(AirPortChart airPortChart)
        {
            _airPortChartRep.Insert(airPortChart);
        }

        public async Task InsertAsync(AirPortChart airPortChart)
        {
            await _airPortChartRep.InsertAsync(airPortChart);
        }

        public IQueryable<AirPortChart> GetAll()
        {
            return _airPortChartRep.GetAll();
        }

        public Task<AirPortChart> GetByIdAsync(string airPortId)
        {
            return _airPortChartRep.FirstOrDefaultAsync(airPortId);
        }

        public Task UpdateAsync(AirPortChart airPortChart)
        {
            return _airPortChartRep.UpdateAsync(airPortChart);
        }

        public Task<bool> DeleteAllAsync()
        {
            return _airPortChartRep.DeleteAllAsync();
        }
    }
}
